// 用数组实现栈操作

Array.prototype.peek = function(){
    return this[ this.length - 1 ];
}

let stack = [] ;

console.log( '栈:' + stack.toString() );

stack.push( '5!' );
console.log( '栈:' + stack.toString() );

stack.push( '4!' );
console.log( '栈:' + stack.toString() );

stack.push( '3!' );
console.log( '栈:' + stack.toString() );

stack.push( '2!' );
console.log( '栈:' + stack.toString() );

stack.push( '1!' );
console.log( '栈:' + stack.toString() );

console.log( stack.peek() ) ;
console.log( '栈:' + stack.toString() );

console.log( stack.pop() ) ;
console.log( '栈:' + stack.toString() );

console.log( stack.pop() ) ;
console.log( '栈:' + stack.toString() );

console.log( stack.pop() ) ;
console.log( '栈:' + stack.toString() );

console.log( stack.pop() ) ;
console.log( '栈:' + stack.toString() );

console.log( stack.pop() ) ;
console.log( '栈:' + stack.toString() );